package com.chonglie;

import android.app.Activity;
import android.os.Bundle;
import android.view.ViewGroup;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;

/**
 * @author chonglie
 * 
 */
public class HelloWorldActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.hello_world);
		fillTableLayout();
	}

	private void fillTableLayout() {
		TableLayout layout = (TableLayout) findViewById(R.id.helloworld_tablelayout_01);
		layout.setStretchAllColumns(true);

		TableRow tr = null;
		TextView tv = null;
		for (int row = 0; row < 10; row++) {
			tr = new TableRow(this);

			for (int col = 0; col < 8; col++) {
				tv = new TextView(this);
				tv.setText("[" + row + "," + col + "]");
				tr.addView(tv);
			}
			layout.addView(tr, new TableLayout.LayoutParams(
					ViewGroup.LayoutParams.WRAP_CONTENT,
					ViewGroup.LayoutParams.MATCH_PARENT));
		}

	}
}
